<!--
 * @Author: Cenven
 * @Date: 2021-06-18 15:22:39
 * @Description: 北京泓深教育发展有限公司
 * @Descripttion: 
 * @version: @Lastest
 * @LastEditTime: 2021-06-18 18:17:51
 * @CopyRight: 北京泓深教育发展有限公司
-->
<template>
  <div class="page-app_download">
    <!-- <white-header :isShowTopNav="true" :isShowBack="true" :isShowRight="true" title="APP下载"></white-header> -->
    <div class="logo-img">
        <img :src="web_info.COMPANY_LOGO" alt="logo">
    </div>
    <p class="platform">{{web_info.SYSTEM_NAME}}</p>
    <div class="bottom_box">
        <div class="download_btn" @click="downloadApp()">立即下载APP</div>
    </div>
  </div>
</template>
<script>
import { mapState, mapActions, mapMutations } from "vuex";
import WhiteHeader from "~/components/mobile/WhiteHeader.vue";
export default {
  name: "app-download",
  components: {
    WhiteHeader
  },
  data() {
    return {};
  },
  created() {},
  computed: {
    ...mapState({
      web_info(state) {
        return state.web_info;
      }
    })
  },
  mounted() {},
  activated() {},
  methods: {
    ...mapMutations(["SET_IS_LOADING"]),
    downloadApp(){
        let ua = navigator.userAgent.toLowerCase();
        if (/iphone|ipad|ipod/.test(ua)) {
            alert('暂不支持苹果端下载哟');
        } else if (/android/.test(ua)) {
            if ("download" in document.createElement("a")) {
            // 非IE下载
                const elink = document.createElement("a");
                elink.download = this.web_info.SYSTEM_NAME + ".apk";
                elink.style.display = "none";
                elink.href = this.web_info.ANDROID_APP_URL;
                document.body.appendChild(elink);
                elink.click();
                URL.revokeObjectURL(elink.href); // 释放URL 对象
                document.body.removeChild(elink);
            } else {
                // IE10+下载
                navigator.msSaveBlob(content, fileName);
            }
        }
    },
    formatDate(timestamp) {
      let date = new Date(timestamp);
      let year = date.getFullYear();
      let month = date.getMonth() + 1;
      let day = date.getDate();
      let hour = date.getHours();
      let minute = date.getMinutes();
      let second = date.getSeconds();
      let add0 = m => {
        return m < 10 ? "0" + m : m;
      };
      let showTime = null;
      if (new Date(timestamp).toDateString() === new Date().toDateString()) {
        if (hour < 10) {
          showTime = "上午";
        } else if (hour < 12) {
          showTime = "中午";
        } else if (hour < 18) {
          showTime = "下午";
        } else {
          showTime = "晚上";
        }
        // console.log("今天", showTime + " " + add0(hour) + ":" + add0(minute));
        return showTime + " " + add0(hour) + ":" + add0(minute);
      } else {
        // console.log("以前", add0(year) + "/" + add0(month) + "/" + add0(day));
        return add0(year) + "/" + add0(month) + "/" + add0(day);
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.page-app_download {
  min-height: 100vh;
  font-size: 0.3rem;
  padding: 0.3rem;
  background: #f7f7fa;
  .logo-img{
    width: 3.5808rem;
	height: .7488rem;
    margin: 26vh auto 0;
    img{
        width: 100%;
        height: 100%;
        display: block;
    }
  }
  .platform{
    text-align: center;
    margin-top: .864rem;
    font-size: .34559rem;
	letter-spacing: .0384rem;
	color: var(--theme-color);
  }
  .bottom_box{
      position: fixed;
      bottom: 0;
      left: 0;
      width: 7.2rem;
      height: 1.3248rem;
      background: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      .download_btn{
        width: 6.2688rem;
        height: .8448rem;
        background-color: var(--theme-color);
	    border-radius: .4224rem;
        font-size: .34559rem;
        text-align: center;
        line-height: .8448rem;
	    color: #fefefe;
      }
  }
}
</style>
